import BaseService from "./BaseService";

/**
 * 购物车服务类
 */
export default class OrderService extends BaseService {
  constructor() {
    super();
  }

  create(unionid, addressId, skuId, courseIds) {
    const url = `${this.host}/orders?unionid=${unionid}&skuId=${skuId}&addressId=${addressId}&courseIds=${courseIds}`;
    return this.post(url).then(data => data != '' ? data : Promise.reject('CREATE_ORDER_FAIL'));
  }

  list(unionid) {
    const url = `${this.host}/orders?unionid=${unionid}`;
    return this.get(url).then(data => data != '' ? data : Promise.reject('LIST_ORDER_FAIL'));
  }
  

  load(code) {
    const url = `${this.host}/orders/${code}`;
    return this.get(url).then(data => data != '' ? data : Promise.reject('LOAD_ORDER_FAIL'));
  }
}